package br.com.arken.spring.core.util;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public class ReflectionUtil {

	@SuppressWarnings("unchecked")
	public static <E> Class<E> getType(Object obj) {
		Type genericSuperClass = obj.getClass().getGenericSuperclass();
		
		if(obj.getClass().getName().contains("$$EnhancerByCGLIB$$"))
			genericSuperClass = obj.getClass().getSuperclass().getGenericSuperclass();
		
		return (Class<E>) ((ParameterizedType) genericSuperClass).getActualTypeArguments()[0];
	}

}
